var showCharts;
require(['highcharts'], function () {
	
	showCharts = function(lineId,organId,rcrdTime,spedCnt,revupCount,sharpSldnCount,bhv7count,bhv5count,
			lineName,organName,drvName,licPltNo,sctBhvDura,ecnSpdOfMotVhiDura,beginTime,endTime,analysisType){
		var sctAr = sctBhvDura.split("'");
		var sctDura = parseFloat(sctAr[0])*60 + parseFloat(sctAr[1]) + parseFloat(sctAr[2])/60;
		var ecnAr = ecnSpdOfMotVhiDura.split("'");
		var ecnDura = parseFloat(ecnAr[0])*60 + parseFloat(ecnAr[1]) + parseFloat(ecnAr[2])/60;
		$("#drvBehaviorAnalysisChart").empty();
		//查询
		 var params = [];
		 var resultArr = [];
		 var avgArr = [];
		 var duraArr = [];
		 var avgDuraArr = [];
		 params.push({
			name : "beginTime",
			value : beginTime
		},{
			name : "endTime",
			value : endTime
		},{
			name : "addDrvAnalysis",
			value : analysisType
		},{
			name : "lineId",
			value : lineId
		},{
			name : "organId",
			value : organId
		});
		$.ajaxExt({
			url : "/drvBehaviorAnalysis/searchLineEnergyChart.htm",
			data : params
		}).done(function(result){
			resultArr.push(spedCnt);
			resultArr.push(revupCount);
			resultArr.push(sharpSldnCount);
			resultArr.push(bhv7count);
			resultArr.push(bhv5count);
			resultArr.push(0);
			avgArr.push(result[0].spedCnt);
			avgArr.push(result[0].revupCount);
			avgArr.push(result[0].sharpSldnCount);
			avgArr.push(result[0].bhv7count);
			avgArr.push(result[0].bhv5count);
			avgArr.push(0);
			duraArr.push(0);
			duraArr.push(0);
			duraArr.push(0);
			duraArr.push(0);
			duraArr.push(sctDura);
			duraArr.push(ecnDura);
			avgDuraArr.push(0);
			avgDuraArr.push(0);
			avgDuraArr.push(0);
			avgDuraArr.push(0);
			var avgSctAr = result[0].sctBhvDura.split("'");
			var avgSctDura = parseFloat(avgSctAr[0])*60 + parseFloat(avgSctAr[1]) + parseFloat(avgSctAr[2])/60;
			var avgEcnAr = result[0].ecnSpdOfMotVhiDura.split("'");
			var avgEcnDura = parseFloat(avgEcnAr[0])*60 + parseFloat(avgEcnAr[1]) + parseFloat(avgEcnAr[2])/60;
			avgDuraArr.push(avgSctDura);
			avgDuraArr.push(avgEcnDura);
			$("#drvBehaviorAnalysisChart").highcharts({
			   title: {
		             text: ''
		         },
		         xAxis: {
		             categories: ['超速','急加速','急减速','ABS','空档滑行','经济车速'],
		             lineWidth: 1,
		             lineColor: '#808080'
		         },
		         credits: {
		             enabled: false
		         },
		         yAxis: [ // Primary yAxis 
		            {
			         	title: { text: '次数', style: { color: '#89A54E' } }, 
			         	opposite: false 
		         	}, 
		         	{  
		         		title: { text: '', style: { color: '#4572A7' } }
		         	},
		         	{ 
		         		title: { text: '运行时长(分钟min)', style: { color: '#AA4643' } }, 
		         		opposite: true 
		         	},
		         	{ 
		         		title: { text: '', style: { color: '#4572A7' } }
		         	},   
		         
		         ],
		         tooltip: {
		             shared: true,
		             valueDecimals: 0
		         },
		          series: [
		             {
		                 name: '次数',
		                 type: 'column',
		                 color: '#FF9A00',
		                 yAxis:0,
		                 data:  resultArr
		             },
		             {
		                 name: '线路平均次数',
		                 type: 'column',
		                 color: '#74C4D4',
		                 //yAxis:1,
		                 data: avgArr
		             }
		             ,
		             {
		                 name: '时长',
		                 type: 'column',
		                 color: '#9BCA63',
		                 yAxis:2,
		                 data: duraArr
		             }
		             ,
		             {
		                 name: '线路平均时长',
		                 type: 'column',
		                 color: '#D7504B',
		                 yAxis:2,
		                 data: avgDuraArr
		             }
		         ] 
		     });
		}); 
	};
	
});